package com.linran.javaweb.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Builder;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * @author lin
 * @AssertFalse 校验false
 * @AssertTrue 校验true
 * @DecimalMax(value=,inclusive=) 小于等于value，
 * inclusive=true,是小于等于
 * @DecimalMin(value=,inclusive=) 与上类似
 * @Max(value=) 小于等于value
 * @Min(value=) 大于等于value
 * @NotNull 检查Null
 * @Past 检查日期
 * @Pattern(regex=,flag=) 正则
 * @Size(min=, max=)  字符串，集合，map限制大小
 * @Valid 对po实体类进行校验
 * @date 2020-05-10 20:27
 */
public class User {
    @Size(min = 1, max = 10, message = "姓名长度必须为1到10")
    private String name;

    @NotEmpty
    private String firstName;

    @Min(value = 10, message = "年龄最小为10")
    @Max(value = 100, message = "年龄最大为100")
    private Integer age;


    //@Future
    //@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")//只对get参数起作用
    //@JSONField(format = "yyyy-MM-dd HH:mm:ss") //出参
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")//入参/出参
    private Date birth;

    private LocalDateTime ctime;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Date getBirth() {
        return birth;
    }

    public void setBirth(Date birth) {
        this.birth = birth;
    }

    public LocalDateTime getCtime() {
        return ctime;
    }

    public void setCtime(LocalDateTime ctime) {
        this.ctime = ctime;
    }
}
